/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package teamBlitz;

import edu.wpi.first.wpilibj.AnalogChannel;
import edu.wpi.first.wpilibj.DigitalOutput;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Ultrasonic;

/**
 *
 * @author danielle
 */
public class MaxSonar extends AnalogChannel
{
    Ultrasonic my;
    private static double scale = 5.08/1024.0;
    private DigitalOutput m_Ranging;
    public MaxSonar(int moduleNumber, int channel) 
    {
        super(moduleNumber, channel);
    }

    public MaxSonar(int channel) 
    {
        super(channel);
    }
    boolean init(int moduleNumber, int channel)
    {
        m_Ranging = new DigitalOutput(moduleNumber, channel);
        m_Ranging.set(false);
        return(true);
    }
    double getDistance()
    {
        m_Ranging.set(true);
        Timer.delay(.001);
        double in = getVoltage();
        //System.out.println("in="+in+"  scale="+scale );
        double distance = in/scale;
        m_Ranging.set(false);
        return distance;
    }
    
}
